<!DOCTYPE html>
<html>
<head>
    <title>分类 - 我的 beego 博客</title>
    {{template "header" .}}
</head>
<body>
{{template "navbar" .}}
<div class="container">
    <div class="page-header"></div>
    <h1>分类列表</h1>
    <form method="get" action="/category">
        <div class="form-group">
            <label>分类名称：</label>
            <input class="form-control" id="name" name="name" placeholder="Enter category">
        </div>
        <input type="hidden" name="op" value="add">
        <button type="submit" onclick="return checkInput();" class="btn btn-default">添加</button>
    </form>
    <script type="text/javascript">
        function checkInput() {
            let e = document.getElementById("name");
            if (e.value.length == 0) {
                alert("请输入分类名称")
                return false
            }
            return true
        }
    </script>
    <table class="table table-striped">
        <thead>
        <tr>
            <th>#</th>
            <th>名称</th>
            <th>文章数</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {{range .Categories}}
            <tr>
                <th>{{.Id}}</th>
                <th>{{.Title}}</th>
                <th>{{.TopicCount}}</th>
                <th><a href="/category?op=del&id={{.Id}}">删除</a></th>
            </tr>
        {{end}}
        </tbody>

    </table>
</div>

<script type="text/javascript" src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript" src="/static/js/bootstrap.min.js"></script>
</body>
</html>